From: Giovanni Campagna Date: Sun, 16 Dec 2012 23:42:40 +0000 (+0100) Subject: WindowOverlay: fix title sizing X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~5203 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=944762ac830cb5401d5447da55ed667212f7ee71;p=gnome-shell.git WindowOverlay: fix title sizing After the first time the title was placed, we were setting its width, thus forcing get_preferred_width() to return that as the minimum and natural width. To workaround that, explicitly reset the width to -1, -1, causing StLabel->get_preferred_width() to be called, which would give us a meaningful value for minimum and natural width. https://bugzilla.gnome.org/show_bug.cgi?id=688234 --- diff --git a/js/ui/workspace.js b/js/ui/workspace.js index acbcd377a..25877b20b 100644 --- a/js/ui/workspace.js +++ b/js/ui/workspace.js @@ -557,8 +557,16 @@ const WindowOverlay = new Lang.Class({ else button.set_position(Math.floor(buttonX), Math.floor(buttonY)); + // Clutter.Actor.get_preferred_width() will return the fixed width if one + // is set, so we need to reset the width by calling set_width(-1), to forward + // the call down to StLabel. + // We also need to save and restore the current width, otherwise the animation + // starts from the wrong point. + let prevTitleWidth = title.width; + title.set_width(-1); let [titleMinWidth, titleNatWidth] = title.get_preferred_width(-1); let titleWidth = Math.max(titleMinWidth, Math.min(titleNatWidth, cloneWidth)); + title.width = prevTitleWidth; let titleX = cloneX + (cloneWidth - titleWidth) / 2; let titleY = cloneY + cloneHeight + title._spacing;